﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DAL;
using DTO;
namespace DBL
{
    public class User_DAL
    {
        SqlCommand cmd;

        #region User_Insert
        public void User_Insert(User user)
        {
            cmd = new SqlCommand("sp_User_Insert", Connect.Connected());
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Name",user.Name));
            cmd.Parameters.Add(new SqlParameter("@UserName", user.UserName));
            cmd.Parameters.Add(new SqlParameter("@Password", user.Password));
            cmd.Parameters.Add(new SqlParameter("@Rule", user.Rule));
            cmd.Parameters.Add(new SqlParameter("@Status", user.Status));
            cmd.ExecuteNonQuery();
        }

        #endregion
        #region User_Update
        public void User_Update(User user)
        {
            cmd = new SqlCommand("sp_User_Update", Connect.Connected());
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Id", user.Id));
            cmd.Parameters.Add(new SqlParameter("@Name", user.Name));
            cmd.Parameters.Add(new SqlParameter("@UserName", user.UserName));
            cmd.Parameters.Add(new SqlParameter("@Password", user.Password));
            cmd.Parameters.Add(new SqlParameter("@Rule", user.Rule));
            cmd.Parameters.Add(new SqlParameter("@Status", user.Status));
            cmd.ExecuteNonQuery();
        }

        #endregion
        #region User_Delete
        public void User_Delete(string id)
        {
            cmd = new SqlCommand("sp_User_Delete", Connect.Connected());
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@Id", id));          
            cmd.ExecuteNonQuery();
        }

        #endregion

     
    }
}
